<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
	<style>

	</style>
</head>
<body>
	<script>
		function fn1() {
			console.log(arguments)
			let arr = Array.prototype.slice.call(arguments)
			const inner = function inner() {
				// 一个函数访问外部变量,形成闭包
				arr.push(...arguments)
				console.log(arr)
				return inner
			}
			
			// 获取返回值需要调用getValue
			// 可以通过__proto__[Symbol.toPrimitive],当使用该函数返回值和原始数据类型做计算时,直接返回当前函数的返回值
			inner.__proto__[Symbol.toPrimitive] = function() {
				return arr.reduce((res, ele) => {
					return res + ele
				})
			}


			return inner
		}
		const res = fn1(1,2,3)(4,5,6)(2)
		// const num = res.getValue()
		console.log(res + 9999)
	</script>
</body>
</html>